package com.ruoyi.dynamic.controller.app;

import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.pojo.vo.SingleVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.common.core.utils.CommonUtils;
import com.ruoyi.dynamic.model.pojo.entity.RoomSpac;
import com.ruoyi.dynamic.service.IRoomSpacService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "App-房间玩法词库", description = "App-房间玩法词库")
@RestController
@RequestMapping(PathConstant.APP_PATH + "room-spac")
public class AppRoomSpacController {

    @Autowired
    private IRoomSpacService iRoomSpacService;

    @Operation(summary = "随机获取词库 type传0,1", description = "随机获取词库")
    @GetMapping("listPage")
    public SingleVO<String> listPage(@Parameter(description = "0心动交友1你画我猜") Integer type) {
        RoomSpac one = iRoomSpacService.lambdaQuery()
                .eq(!CommonUtils.isNull(type), RoomSpac::getType, type)
                .last("ORDER BY RAND() LIMIT 1").one();
        return Result.single(one.getTitle());
    }


}
